<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once(__Modules_Path."/mysql_wrappers.lib.php");

global $_Conn;
global $_ConnQuery;
global $_ConnMaster;
global $_blDBHostM;	//Master
global $_blDBHostQ;	//Slave
global $_blDBHostH;	//History
global $_blDBHostR;	//Result
global $_blDBUser;
global $_blDBPass;
global $_blDBName;
global $_blWeb;
global $_blErrorMailTo;

$_blDBHostM = "";		//Master
$_blDBHostQ = "";		//Slave
$_blDBHostOld = "";	//Old REport Server
$_blDBUser = "";
$_blDBPass = "";
$_blDBName = "";
$_blWeb = "";
$_blErrorMailTo = "";

$arrErr = DBConnection($_DBSite);
if(sizeof($arrErr) > 0){
	if($_isDBExist == "no"){
		$_strLogErr = $arrErr["Content"]."<br />\n";
	}else{
		mail($_blErrorMailTo, $arrErr["Subject"]."(".$_blWeb.")", $arrErr["Content"], "From:".$_blWeb."<apache@secure.".$_blWeb.">");
		$GLOBALS["errormessage"] = $arrErr["Subject"];
		$GLOBALS["errorhidden"] = $arrErr["Content"];
		ErrMsgOutputHTML("Error", "", 1);
	}
}
/*
global $_Conn;
switch($_DBSite){
	case "Result":	//結帳資料庫
		$_BetDBHost = "localhost";
		$_Conn = "_ConnResult";
		global $_ConnResult;
		break;
	
	case "History":
	case "Query":	//查詢資料庫
		$_BetDBHost = "localhost";
		$_Conn = "_ConnQuery";
		global $_ConnQuery;
		break;

	case "Master":	 //主資料庫
	default:	 //預設
		$_BetDBHost = "localhost";
		$_Conn = "_ConnMaster";
		global $_ConnMaster;
		break;
}

$_BetDBUser = "root";
$_BetDBPass = "";
$_BetDBName = "betNewLotto";
$_BetWeb = "lottou.uuss.net";

if (! $$_Conn = @mysql_connect($_BetDBHost, $_BetDBUser, $_BetDBPass)) {
	?>
	系統維護中，請稍候再登入！不便之處，敬請見諒！！
	<!--系統維護中, 請<a href="javascript:location.reload();">重新整理</a><P>//-->
	<?php
	$email = "service@".$_BetWeb;
	$subject = " mysql_connect error (".$_BetWeb.")";
	$content = "連線錯誤：無法連線至資料庫主機！\nDBSite".$_DBSite."\nPage: ".$_SERVER["PHP_SELF"]."\n";
	if($_isDBExist == "no"){
		$_strLogErr = $content."<br />\n";
	}else{
		//mail($email, $subject, $content, "From:".$_BetWeb."<apache@secure.".$_BetWeb.">");
		exit();
	}
}
PMA_mysql_query("SET NAMES 'utf8'");
if (! @PMA_mysql_select_db($_BetDBName, $$_Conn)) {
	?>
	系統維護中，請稍候再登入！不便之處，敬請見諒！
	<!--系統忙碌中, 請稍候片刻, 或立即<a href="javascript:location.reload();">重新整理</a>.//-->
	<script>
	function abc() {
		location.reload();
	}
	setInterval(abc,60000);
	</script>
	<?php 
	$email = "service@".$_BetWeb;
	$subject = "mysql_select_db error (".$_BetWeb.")";
	$content = "連線錯誤：無法連結資料庫！\nDBSite".$_DBSite."\nPage: ".$_SERVER["PHP_SELF"]."\n".PMA_mysql_error($$_Conn);
	$content .= "\nAccount=".$_SESSION["MemberInfo"] -> Account;
	if($_isDBExist == "no"){
		$_strLogErr = $content."<br />\n";
	}else{
		mail($email, $subject, $content, "From:".$_BetWeb."<apache@secure.".$_BetWeb.">");
		exit();
	}
}*/
?>